import Vue from 'vue'
export default {

	state:{
		List: [{
				name: '混蛋马腾飞',
				phone: '18225517585',
				email: '15551245@qq.com',
				path: '',
				province: '安徽省',
				city: '合肥市',
				district: '新站区',
				address: '华润熙云府5#502',
				default: 1
			},
			{
				name: '吊毛姜富豪',
				phone: '18985623589',
				email: '3596852455@qq.com',
				path: '',
				province: '安徽省',
				city: '合肥市',
				district: '高新区',
				address: '保利梧桐语6#703',
				default: 0
			}
		]
	},
	mutations:{
		// 编辑地址
		editAddress(state,{index,item}){
			console.log('111222333444=>',index,item);
			Vue.set(state.List, index, item)
			if (state.List[index].default) {
				state.List.forEach(v => v.default = 0)
				state.List[index].default = true
			}
		},
		// 删除地址
		delAddress(state,payload){
			uni.showModal({
				title: '提示',
				content: '您确定要删除该条信息吗',
				success: (res) => {
					if (res.confirm) {
						console.log('用户点击确定');
						state.List.splice(payload, 1)
			
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			});
		},
		// 添加新地址
		addAddress(state,payload){
			console.log('payload=>',payload);
			state.List.unshift(payload);
			if (payload.default) {
				state.List.forEach(v => v.default = 0)
				payload.default = true
			}
		}
	},
	getters:{
		
	},
	actions:{
		
	}
}